Declarative Syntax Tree Engineering Or, One Grammar to Rule Them All

نویسنده

  • Robert Grimm
چکیده

Grammars for many parser generators not only specify a language’s syntax but also the corresponding syntax tree. Unfortunately, most parser generators pick a somewhat arbitrary combination of features from the design space for syntax trees and thus lock in specific trade-offs between expressivity, safety, and performance. This paper discusses the three major axes of the design space—specification within or outside a grammar, concrete or abstract syntax trees, and dynamically or statically typed trees—and their impact. It then presents algorithms for automatically realizing all major choices from the same, unmodified grammar with inline syntax tree declarations. In particular, this paper shows how to automatically (1) extract a separate syntax tree specification, (2) embed an abstract syntax tree within a concrete one, and (3) infer a strongly typed view on a dynamically typed tree. All techniques are implemented in the Rats! parser generator and have been applied to real-world C and Java grammars and their syntax trees.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Query Processing and Optimization using Compiler Tools

We propose a rule-based approach for (X)Query compilation that operates on a single query representation—called abstract syntax tree (AST)—throughout the whole translation and transformation process. For this purpose, we exploit some new features of the ANTLR compiler generator such as tree pattern matching. This approach avoids error-prone transformations into different internal query represen...

متن کامل

Disambiguation Filters for Scannerless Generalized LR Parsers

Several real-world problems call for more parsing power than is offered by the widely used and well-established deterministic parsing techniques. These techniques also create an artificial divide between lexical and context-free analysis phases, at the cost of significant complexity at their interface. In this paper we present the fusion of generalized LR parsing and scannerless parsing. This c...

متن کامل

The Syntax and Semantics of Punctuation and Its Use in Interpretation

In this paper, I argue for a declarative description of the syntax and semantics of punctuation marks (in English) couched in a feature/uniication-based phrase structure formalism, describe how Nunberg's (1990) syntactic analysis of punctuation can be combined with Dale's (1991) suggested semantic analysis within this framework, and present experimental evidence that 1) the resulting text gramm...

متن کامل

Grammar Re-Engineering for Language Centered Software Engineering

This paper describes a systematic approach to grammar re-engineering by transforming conventional restricted YACC grammars from legacy code into the purely declarative syntax definition formalism SDF. The declarative nature of SDF and its ability to handle the full class of context-free grammars allows grammar definitions that are more readable and maintainable compared to the original YACC gra...

متن کامل

Towards Zero-Overhead Disambiguation of Deep Priority Conflicts

Context Context-free grammars are widely used for language prototyping and implementation. They allow formalizing the syntax of domain-specific or general-purpose programming languages concisely and declaratively. However, the natural and concise way of writing a context-free grammar is often ambiguous. Therefore, grammar formalisms support extensions in the form of declarative disambiguation r...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2007